package models
{
	import mx.collections.ArrayCollection;
	
	public class UMLClass extends Resource
	{
		public function UMLClass(projectId:int = 0, name:String = "") {
			super(new XML('<class />'));
			this.name = name;
			this.projectId = projectId;
			this.userClass = false;
		}

		public function get oid() : int {
			return _node.@oid;
		}
		public function set oid(oid:int) : void {
			_node.@oid = oid;
		}
		
		public function get projectId() : int {
			return _node.@projectId;
		}
		public function set projectId(projectId:int) : void {
			_node.@projectId = projectId;
		}
		
		public function get name() : String {
			return _node.@name;
		}
		public function set name(name:String) : void {
			_node.@name = name;
		}
		
		public function get userClass() : Boolean {
			return _node.@userClass;
		}
		public function set userClass(userClass:Boolean) : void {
			_node.@userClass = userClass;
		}
		
		public function get interfaceClass() : Boolean {
			return (_node.@interfaceClass.lenth()) ? _node.@interfaceClass : false;
		}
		public function set interfaceClass(interfaceClass:Boolean) : void {
			_node.@interfaceClass = interfaceClass;
		}
		
		public function get abstractClass() : Boolean {
			return (_node.@abstractClass.lenth()) ? _node.@abstractClass : false;
		}
		public function set abstractClass(abstractClass:Boolean) : void {
			_node.@abstractClass = abstractClass;
		}
		
		public function get enumClass() : Boolean {
			return (_node.@enumClass.lenth()) ? _node.@enumClass : false;
		}
		public function set enumClass(enumClass:Boolean) : void {
			_node.@enumClass = enumClass;
		}
		
		public function get parents() : ArrayCollection {
			var parents:ArrayCollection = new ArrayCollection();
			for each(var parent:* in _node.parents.oid) {
				parents.addItem(parent.value);
			}
			return parents;
		}
		
		public function get attributes() : ArrayCollection {
			var attributes:ArrayCollection = new ArrayCollection();
			for each(var xmlAttribute:* in _node.attributes.attribute) {
				var attribute:UMLAttribute = new UMLAttribute();
				attribute.setXML(xmlAttribute);
				attributes.addItem(attribute);
			}
			return attributes;
		}
		
		/* Diagram */
		public function get diagramLabel() : String {
			return this.name;
		} 
	}
}